
use common
go
if exists (select 1 from sysobjects where name = "p_getChildren")
begin
        drop proc p_getChildren
    	IF OBJECT_ID('dbo.p_getChildren') IS NOT NULL
        	PRINT '<<< FAILED DROPPING PROCEDURE dbo.p_getChildren >>>'
    	ELSE
        	PRINT '<<< DROPPED PROCEDURE dbo.p_getChildren >>>'
end
go
create proc p_getChildren 
( @Parent	integer 
) 
as 
begin 
  select *
  from   common..t_ReleaseObjects	a 
  where  a.Parent     = @Parent 
  and    a.CuId      != a.Parent 
  order by a.OrderId
  end 
return 0 
go
grant execute on p_getChildren to public
go
IF OBJECT_ID('dbo.p_getChildren') IS NOT NULL
    PRINT '<<< CREATED PROCEDURE dbo.p_getChildren >>>'
ELSE
    PRINT '<<< FAILED CREATING PROCEDURE dbo.p_getChildren >>>'
go